# -*- coding: utf-8 -*-
import yaml

"""
递归获取平铺后的yaml
Args:
        key: 字典key.
        config: 字典value.
"""
def getTileYml(key, config):
  if len(key) > 0:
    # 拼接完整输出key
    key = ''.join([key, "."])
  for subKey in config.keys():
    value = config[subKey]
    if type(value) == dict: # 递归
      getTileYml(key + subKey, value)
    else:
      tileYml.append((key + subKey, value if value != None else ""))


# main入口
if __name__ == '__main__':
  with open("sample.yaml", 'r') as f:
    tileYml = []
    getTileYml("", yaml.load(f, yaml.FullLoader))
    print(tileYml)
